﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessObjects.BO_GetObjects;
using System.Data;

public partial class Controls_NewsDetails : Base_Controls
{
    int category_id;
    int article_id;
    protected void Page_Load(object sender, EventArgs e)
    {
        category_id = base.getRequest("category_id", 2);
        article_id = base.getRequest("article_id", 0);
        if (!IsPostBack)
        {
            try
            {
                if (article_id > 0)
                {
                    ObjDT = BO_portal_articles.Search(article_id);
                }
                else
                {
                    ObjDT = BO_portal_articles.SearchCategory(category_id);
                }
                if (Lang)
                {
                    ctTitle.InnerHtml = ObjDT.Rows[0]["FULL_ARTICLE_TITLE_ENG"].ToString();
                    ctDetails.InnerHtml = ObjDT.Rows[0]["ARTICLE_DETAIL_ENG"].ToString();
                    if (article_id > 0) Setting.SetMetaTags(ObjDT.Rows[0]["FULL_ARTICLE_TITLE_ENG"].ToString() + " - " + DigiLib.PortalConfig.GetPageTitle, this.Page, ObjDT.Rows[0]["FULL_ARTICLE_TITLE_ENG"].ToString() + " - " + DigiLib.PortalConfig.GetMetaKeywords, ObjDT.Rows[0]["FULL_ARTICLE_DESCRIPTION_ENG"].ToString() + " - " + DigiLib.PortalConfig.GetMetaDescription);
                    ObjDT = BO_portal_articles.SelectMore(10, Convert.ToInt32(ObjDT.Rows[0]["ARTICLE_ID"]), "ARTICLES");
                    foreach (DataRow row in ObjDT.Rows)
                    {
                        row["FULL_ARTICLE_TITLE"] = row["FULL_ARTICLE_TITLE_ENG"].ToString();
                    }
                }
                else
                {
                    ctTitle.InnerHtml = ObjDT.Rows[0]["FULL_ARTICLE_TITLE"].ToString();
                    ctDetails.InnerHtml = ObjDT.Rows[0]["ARTICLE_DETAIL"].ToString();
                    if (article_id > 0) Setting.SetMetaTags(ObjDT.Rows[0]["FULL_ARTICLE_TITLE"].ToString() + " - " + DigiLib.PortalConfig.GetPageTitle, this.Page, ObjDT.Rows[0]["FULL_ARTICLE_TITLE"].ToString() + " - " + DigiLib.PortalConfig.GetMetaKeywords, ObjDT.Rows[0]["FULL_ARTICLE_DESCRIPTION"].ToString() + " - " + DigiLib.PortalConfig.GetMetaDescription);
                    ObjDT = BO_portal_articles.SelectMore(10, Convert.ToInt32(ObjDT.Rows[0]["ARTICLE_ID"]), "ARTICLES");
                }
                base.bindRepeater(rptOther, ObjDT);
            }
            catch
            {
                if (Lang)
                    ctTitle.InnerHtml = "Comming soon...";
                else
                    ctTitle.InnerHtml = "Đang cập nhật...";
                ctDetails.Visible = false;
            }
        }
    }
    protected string setLink(string title, int category_id, string article_id)
    {
        return "/tin-tuc/" + DigiLib.StringUtils.RemoveUnicode(title, "-") + "-c" + category_id.ToString() + "a" + article_id + ".htm";
    }
}